<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>将数组排序，按字母顺序升序排列  </title>
	</head>
	<body>
		<p>点击按钮升序排序数组</p>
		<button onclick="s()">点我</button>
		<script>
			function s(){
				var f=["a","b","c","d"];
				for(var i=1;i<=f.length;i++){
					for(var j=0;j<f.length-i;j++){
						if(f[j]>f[j+1]){
							var t=f[j];
							f[j]=f[j+1];
							f[j+1]=t;
						}
					}
				}
				for(var i=0;i<f.length;i++){
					document.write(f[i]);
					document.write("<br />");
				}
			}
		</script>
	</body>
</html>
